package com.example.study;

import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;

import javax.annotation.Resource;
import javax.sql.DataSource;


@MapperScan("com.example.study.mapper")
@SpringBootApplication
@EnableScheduling //开启定时任务
@EnableAsync //支持异步执行方法
public class StudyApplication implements CommandLineRunner {

    public static void main(String[] args) {
        SpringApplication.run(StudyApplication.class, args);
    }

    private Logger logger = LoggerFactory.getLogger(StudyApplication.class);

    @Resource(name = "studyDataSource")
    private DataSource ordersDataSource;

    @Resource(name = "usersDataSource")
    private DataSource usersDataSource;


    @Override
    public void run(String... args) {
        // orders 数据源
        logger.info("[run][获得数据源：{}]", ordersDataSource.getClass());

        // users 数据源
        logger.info("[run][获得数据源：{}]", usersDataSource.getClass());
    }

}
